#pragma once
#include<queue>
#include"MySQLConn.h"
#include<mutex>
#include<condition_variable>

class ConnectionPool
{
public:
	static ConnectionPool* getConnectPool();
	ConnectionPool(const ConnectionPool&) = delete;
	ConnectionPool& operator=(const ConnectionPool&) = delete;
private:
	ConnectionPool();
	bool parseJsonFile();
	void produceConnection();
	void recycleConnection();
private:
	std::string m_ip;
	std::string m_user;
	std::string m_passwd;
	std::string m_dbName;
	unsigned short m_port;
	int m_minSize;
	int m_maxSize;
	int m_timeout;
	int m_maxIdleTime;
	std::queue<MySQLConn*>m_connectionQ;
	std::mutex m_mutexQ;
	std::condition_variable m_cond;
};

